nurbsTrim -- NURBS surface trimmed by a NURBS curve

HUB | Up | Pheedbak | Download | Tree | Topic | A-Z | Search | Hot | New


    
  "Trimming NURBS surfaces is considered an advanced topic.  
  If this is your first exposure to a NURBS, experiment 
  first with curves and surfaces, then move on to trimmed 
  surfaces."
                         Josie Wernecke, The Inventor Mentor

No foolin', Josie! There are some fine points of trimming NURBS that are probably documented somewhere, but I came upon them the hard way.

This directory contains examples of trimmed NURBS in OpenGL and in Inventor, implemented in nurbsTrim.c and nurbsTrim.iv, as well as an easy Makefile and this README.

To make sense of the examples, make sure you know the NURBS basics, then read about the obstacles I encountered along the way to making trimmed NURBS work.

Good background reading can be found in chapter 11, "Evaluators and NURBS", of the OpenGL Programming Guide, especially in the section on "The GLU NURBS Interface" (pages 343-353), and in chapter 8, "Curves and Surfaces", of The Inventor Mentor, especially in the section on "NURBS Surfaces" (pages 199-207). The complete bibliographic references are

Knot values for NURBS curves and surfaces are not important; the only thing that matters is the values of the knots relative to one another. Knot vectors must be monotonically non-decreasing, and when the same knot value is repeated k times, the curve or surface displays an (N-k)th order discontinuity, where N is the order of the NURBS. This is widely known and well documented.

But not so widely known is that knot values for trimmed NURBS surfaces do indeed matter. The control points of the profile curve must all reside in a rectangle in U-V space defined by the knot vectors of the NURBS surface. Control points outside of this rectangle cause the surface not to be rendered.

In the Inventor example, the knot vectors of the NURBS surface are

There are 10 U knots, and the surface has 6 U control points, so it is of order 4 (=10-6) in the U dimension. Likewise, because there are 9 V knots and 5 V control points, it is of order 4 (=9-5) in the V dimension.

Because the order is 4, notice the 4th and (numKnots-4)th knots. These knots define the boundaries of the valid region in U-V space where the surface is actually visible. Counting 4 knots in, from the ends of the U knot vector, we see knots with values of 3 and 6. Likewise, counting 4 knots in from both ends of the V knot vector, we see knots with values of 2 and 4.

The values for the control points of the NURBS profile curve must fall into the rectangle in U-V space defined by [(3,2),(6,4)]. The points of the profile curve are, in fact,

Another tricky area with NURBS profile curves is clearly documented but easy to forget: curve orientation. The first profile on a trimmed surface must be CCW in U-V parameter space. A CCW profile trims the region outside the closed loop formed by the curve (or curves). A CW profile trims the region inside the closed loop. The rule of thumb is that the trimmed region always lies to the right of the trimming curve as you traverse from beginning to end.

If you can't get your trimmed NURBS surfaces to display in inventor, install inventor_dev.sw.debug, and use the Inventor Debug libraries. Then set:

and when you run ivview from the shell prompt, the debug library will sometimes reveal your error.

I have tested the examples on an Indigo 2 Extreme, running Irix 5.2 and Inventor 2.0. Results may vary on other platforms.

Thanks to Dave Immel and Derrick Burns for the geometry lessons, and to Paul David for trampling the path a few steps ahead of me.

                                      Aaron Schuman


Select any combo of files you'd like to send yourself a compressed tar image of. Executables/scripts are indicated with a trailing `*' character. (Depending upon the browser, it may be necessary to hold down the Ctrl key to select/deselect disjoint items.) a compressed tar image of the above-selected items.
OR, ...
a compressed tar image of the entire nurbsTrim directory.

Copyright © 1995, Silicon Graphics, Inc.